package com.wujunshen.designpattern.creational.factory.simplefactory.instance;

import com.wujunshen.designpattern.creational.factory.BrandOne;
import com.wujunshen.designpattern.creational.factory.BrandTwo;

import java.lang.reflect.InvocationTargetException;
import java.util.Objects;

import static com.wujunshen.designpattern.creational.factory.Constants.BRAND_ONE;
import static com.wujunshen.designpattern.creational.factory.Constants.BRAND_TWO;

/**
 * @author frank woo(吴峻申) <br>
 *     email:<a href="mailto:frank_wjs@hotmail.com">frank_wjs@hotmail.com</a> <br>
 * @date 2021/2/16 23:56<br>
 */
public class Client {
  public static void main(String[] args)
      throws InvocationTargetException, NoSuchMethodException, InstantiationException,
          IllegalAccessException {
    SimpleFactory.registerProduct(BRAND_ONE, new BrandOne());
    SimpleFactory.registerProduct(BRAND_TWO, new BrandTwo());

    Objects.requireNonNull(SimpleFactory.createProduct(BRAND_ONE)).doSomething();
    Objects.requireNonNull(SimpleFactory.createProduct(BRAND_TWO)).doSomething();
  }
}
